<?php

namespace App\Module\Api\Controllers;
use App\Exceptions\Customize\ParamsException;
use App\Module\Api\Controllers\Request\QueryIdRequest;
use App\Module\Api\Validator\CommonIdValidator;
use App\Module\Api\Validator\OrderStatusUpdateValidator;
use App\System\Base\Services\TokenService;
use App\System\Order\Repositories\OrderInfoRepository;

/**
 * 订单状态更新
 * @package App\Module\Admin\Controllers
 */
class OrderStatusUpdateController extends Controller
{
    public function __construct()
    {
        $this->query = new QueryIdRequest();
        parent::__construct();
    }

    public function index()
    {
        (new OrderStatusUpdateValidator())->check();
        $order = OrderInfoRepository::getInstance();
        $user_id = TokenService::getUserId();
        $order_info = $order->updateStatus($this->query,$user_id);
        if(!$order_info)
        {
            throw new ParamsException([
                'error_code' => '1000',
                'message'    => '订单状态更新失败',
            ]);
        }
        return apiResponse();
    }
}
